package com.yanq.liancar.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanq.liancar.R;
import com.yanq.liancar.bean.MyFindBean;
import com.yanq.liancar.bean.UserFindAttentionBean;

import java.util.List;

public class MyfindAdapter extends BaseQuickAdapter<UserFindAttentionBean.DataBean,BaseViewHolder> {
    public MyfindAdapter(int layoutResId, @Nullable List<UserFindAttentionBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, UserFindAttentionBean.DataBean item) {
        helper.setText(R.id.news_title, item.getNewsname())
                .setText(R.id.news_content, item.getNewscontent())
                .setText(R.id.dianzan, item.getNewslikesnum() + "")
                .setText(R.id.pinglun, item.getNewscommentnum() + "")
                .setText(R.id.shoucang, item.getNewsattentionnum() + "")
                .addOnClickListener(R.id.dianzan)
                .addOnClickListener(R.id.pinglun)
                .addOnClickListener(R.id.shoucang)
                .addOnClickListener(R.id.img_checked);

        Glide.with(mContext).load(item.getNewsimage()).into((ImageView) helper.getView(R.id.news_img1));
        ImageView img_status = helper.getView(R.id.img_checked);
        if (item.isGone()){
            img_status.setVisibility(View.VISIBLE);
        }else {
            img_status.setVisibility(View.GONE);
        }
        if (item.isStatus()) {
            img_status.setImageResource(R.drawable.checked);
        } else {
            img_status.setImageResource(R.drawable.unchecked);
        }
    }
}
